<%@include file="/WEB-INF/common/taglibs.jsp"%>
<script type="text/javascript"
	src="${ctx}/resources/js/datatable-query.js"></script>
<div class="row-fluid">
<div class="span12">
<div class="box gradient">
<div class="title">
		<h4><span>Announcement</span>
		</h4>
<a href="#" class="minimize">Minimize</a></div>
<div class="content scrollable clearfix">
<table class="ajaxTable display table table-bordered">
	<thead>
		<tr>
			<th><a id="select_all"><span class="icomoon-icon-checkmark-2"></span></a></th>
 			<th>Author</th>
 			<th>Create Time</th>
			<th>Subject</th>
 		</tr>
	</thead>
</table>
</div>
</div>

</div>

<shiro:hasPermission name="announcement:edit">
	<a href="${ctx}/admin/announcement/create/" class="btn btn-info"> <span
		class="icon12 icomoon-icon-plus white"></span> New</a>
</shiro:hasPermission>
</div>



<script type="text/javascript">

var render = false;
 $(document).ready(function () {
 	johnny.oTable = $('.ajaxTable').dataTable({
		"bLengthChange": true,
		"aoColumnDefs": [
		       		  { 'bSortable': false, 'aTargets': [0,3] }
		       		],
		"sAjaxSource": '${ctx}/admin/announcement/',
		"fnInitComplete": function (oSettings, json) { }
	});


	var name = $("<input>").attr({
		type: "text",
		field: "title",
		op: "cn",
		placeholder: "Title",
		class: "filterdata"
	});
	johnny.initTableQuery(name);
	var config = {
			id : 'del',
			text  : 'Del',
			domain : "Announcement",
			operation : "Delete",
			url : "${ctx}/admin/announcement/del/"
	};
	johnny.tableBtn(config);
 });
var columnHeader = ['','user.name', 'createDate', 'title'];
var QueryData = function (aoData) {
	return johnny.initQueryData(aoData, columnHeader);
}

var DataTableForm = function (json, echo) {
	var dataArray = new Array();
	for (var i = 0; i < json.result.length; i++) {
		var subArray = new Array();
		var value = johnny.getForSelect(json.result[i].id);
 		subArray.push(value);
		var link = "${ctx}/admin/announcement/"+json.result[i].id+"/edit/";
 		subArray.push(json.result[i].user.name);
 		subArray.push(json.result[i].createDate);
 		
 		var controlDiv = $("<div>").addClass("controls center");
 		var comments = $("<a>").attr({
 			href: link,
 			title: "Approve comments"
 		}).addClass("link").appendTo(controlDiv);
 		
 		comments.text(json.result[i].title);
		var span = $('<span/>').text(' - '+json.result[i].content);
		span.appendTo(comments);
		subArray.push(controlDiv.html());
  
		dataArray.push(subArray);
	}
	return {
		sEcho: echo,
		iTotalRecords: json.totalCount,
		iTotalDisplayRecords: json.totalCount,
		aaData: dataArray
	};
}
 
</script>



<body>